cmake_minimum_required(VERSION 3.0)

project(OpenGLWork)

set(CMAKE_CXX_STANDARD 11)

# 设置启动项目
set_property(DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR} PROPERTY VS_STARTUP_PROJECT ${CMAKE_PROJECT_NAME})

file(GLOB SRC_FILES 
    "${PROJECT_SOURCE_DIR}/src/**/*.h"
    "${PROJECT_SOURCE_DIR}/src/Platform/Windows/*.h"
    "${PROJECT_SOURCE_DIR}/src/Platform/OpenGL/*.h"
    "${PROJECT_SOURCE_DIR}/src/Platform/Windows/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/Platform/OpenGL/*.cpp"
    "${PROJECT_SOURCE_DIR}/src/**/*.cpp"
    "${PROJECT_SOURCE_DIR}/vendor/glad/**/*.h"
    "${PROJECT_SOURCE_DIR}/vendor/glad/**/*.c"
    "${PROJECT_SOURCE_DIR}/vendor/glm/**/*.hpp"
    "${PROJECT_SOURCE_DIR}/vendor/glm/**/*.inl"
    "${PROJECT_SOURCE_DIR}/vendor/stb_image/*.h"
)

# 定义源文件夹和目标文件夹
set(SOURCE_DIR ${CMAKE_CURRENT_SOURCE_DIR}/assets)
set(TARGET_DIR ${CMAKE_CURRENT_BINARY_DIR})

# 复制文件夹
file(COPY ${SOURCE_DIR} DESTINATION ${TARGET_DIR})

include_directories(${CMAKE_SOURCE_DIR}/vendor/glad/include 
                    ${CMAKE_SOURCE_DIR}/vendor/glfw/include
                    ${CMAKE_SOURCE_DIR}/vendor/glm
                    ${CMAKE_SOURCE_DIR}/vendor/stb_image
                    ${CMAKE_SOURCE_DIR}/src
                    )

                    
add_executable(${CMAKE_PROJECT_NAME} ${SRC_FILES})
                    
target_link_directories(${CMAKE_PROJECT_NAME} PRIVATE ${CMAKE_SOURCE_DIR}/vendor/glfw/lib)
target_link_libraries(${CMAKE_PROJECT_NAME} PRIVATE glfw3)

add_custom_command(
    TARGET ${CMAKE_PROJECT_NAME}
    POST_BUILD
    COMMAND ${CMAKE_COMMAND} -E copy_directory
            "${PROJECT_SOURCE_DIR}/assets"
            "$<TARGET_FILE_DIR:${CMAKE_PROJECT_NAME}>/assets"
) 